package com.ta.gulimall.coupon.controller;

import java.util.Arrays;

import com.ta.gulimall.common.view.to.SkuFullReductionTo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.ta.gulimall.coupon.entity.SkuFullReductionEntity;
import com.ta.gulimall.coupon.service.SkuFullReductionService;
import com.ta.gulimall.common.utils.system.R;



/**
 * 商品满减信息
 *
 * @author tuao
 * @email tuaoo@gmail.com
 * @date 2022-12-04 16:25:02
 */
@RestController
@RequestMapping("coupon/skufullreduction")
public class SkuFullReductionController {
    @Autowired
    private SkuFullReductionService skuFullReductionService;






    //=================以下是系统代码===================
    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		SkuFullReductionEntity skuFullReduction = skuFullReductionService.getById(id);

        return R.ok().put("skuFullReduction", skuFullReduction);
    }

    /**
     * 保存满减优惠与满减打折与会员价格
     */
    @PostMapping("/save")
    public R save(@RequestBody SkuFullReductionTo skuFullReductionTo){
		skuFullReductionService.saveSkuFullReduction(skuFullReductionTo);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody SkuFullReductionEntity skuFullReduction){
		skuFullReductionService.updateById(skuFullReduction);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		skuFullReductionService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
